package com.hrms.domain;

import java.lang.reflect.Field;
import java.text.ParseException;
import java.util.Date;
import java.util.Map;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.apache.commons.lang.ArrayUtils;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Rating;

@PersistenceCapable(detachable="true")
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class DashBoard extends BusinessObjectImpl {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	@Persistent
	private String userId;
	@Persistent
	private Rating utilization;
	@Persistent
	private Date createTimestamp;

	
	@Override
	public void jdoPreStore() {
		setCreateTimestamp(new Date());
		setUserId(userId.toLowerCase());
	}
	
	@Override
	public Field[] getFields() {
		return (Field[]) ArrayUtils.addAll(DashBoard.class.getDeclaredFields(), super.getFields());		
	}
	
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public Rating getUtilization() {
		return utilization;
	}

	public void setUtilization(Rating utilization) {
		this.utilization = utilization;
	}

	public Date getCreateTimestamp() {
		return createTimestamp;
	}

	public void setCreateTimestamp(Date createTimestamp) {
		this.createTimestamp = createTimestamp;
	}

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}
	public DashBoard() {
		super();
	}
	public DashBoard(Map<String, String[]> parameterMap, String prefix)
			throws IllegalArgumentException, IllegalAccessException,
			ParseException {
		super(parameterMap, prefix);
	}
	public DashBoard(Map<String, String[]> parameterMap)
			throws IllegalArgumentException, IllegalAccessException,
			ParseException {
		super(parameterMap);
	}

}
